package com.etlmaster.executor.trans.core;

import java.util.HashMap;
import java.util.Map;

public class LineMeta {
	private FieldEntry[] fieldMetas;
	public static final int LINE_MAX_FIELD = 1024;
	private Map<String, Integer> colIndex = new HashMap<String, Integer>();

	private int counter=0;
	public LineMeta(){
		setFieldMetas(new FieldEntry[LINE_MAX_FIELD]);
	}
	public void addField(String tableName,String fieldName,String targetTableName,String targetFieldName){
		getFieldMetas()[getCounter()]=new FieldEntry(tableName,fieldName,targetTableName,targetFieldName);
		getColIndex().put(fieldName, getCounter());
		setCounter(getCounter() + 1);
	}
	public void addField(String tableName,String fieldName){
		getFieldMetas()[getCounter()]=new FieldEntry(tableName,fieldName);
		getColIndex().put(tableName.toUpperCase()+"_"+fieldName.toUpperCase(), getCounter());
		setCounter(getCounter() + 1);
	}
	public int getColPosition(String colName){
		return getColIndex().get(colName.toUpperCase());
	}
	public FieldEntry[] getFieldMetas() {
		return fieldMetas;
	}
	public void setFieldMetas(FieldEntry[] fieldMetas) {
		this.fieldMetas = fieldMetas;
	}
	public Map<String, Integer> getColIndex() {
		return colIndex;
	}
	public void setColIndex(Map<String, Integer> colIndex) {
		this.colIndex = colIndex;
	}
	public int getCounter() {
		return counter;
	}
	public void setCounter(int counter) {
		this.counter = counter;
	}
}
